package org.bing.flex.helper {
    import flash.system.Security;


    public class EndpointHelper {
        [Bindable]
        private static var _centerUrl:String;
        [Bindable]
        private static var _collectorUrl:String;

        private static var _instance:EndpointHelper=new EndpointHelper();

        public function EndpointHelper() {
            if (_instance != null) {
                throw Error("Singleton, can't new object!");
            }
        }

        public static function get instance():EndpointHelper {
            return _instance;
        }

        [Bindable]
        public function get currentCenterUrl():String {
            if (_centerUrl == null) {
                // trace("Init center url first!");
                return null;
            }
            Security.loadPolicyFile(_centerUrl + "/crossdomain.xml");
            return _centerUrl;
        }

        [Bindable]
        public function get currentCollectorUrl():String {
            if (_collectorUrl == null) {
                trace("Init collector url first!");
                return null;
            }
            Security.loadPolicyFile(_collectorUrl + "/crossdomain.xml");
            return _collectorUrl;
        }

        public function set currentCenterUrl(url:String):void {
            _centerUrl=url;
        }

        public function set currentCollectorUrl(url:String):void {
            _collectorUrl=url
        }
    }
}